﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="myQuestions.aspx.vb" Inherits="examquestions.myQuestions" validateRequest="false"%>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <div class="page-header">
        <h2>My questions</h2>
      </div>
      Here you can edit or delete your questions. 
    <div class="table-responsive">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" 
        DataKeyNames="questionID" DataSourceID="SqlDataSource1" Width="100%"  class="table table-striped table-hover table-bordered">
        <Columns>
            <asp:BoundField DataField="examBoardID" HeaderText="Exam Board" 
                SortExpression="examBoardID" />
            <asp:BoundField DataField="examTypeID" HeaderText="Exam type" 
                SortExpression="examTypeID" />
            <asp:BoundField DataField="SubjectID" HeaderText="Subject" 
                SortExpression="SubjectID" />
            <asp:BoundField DataField="pointValue" HeaderText="Marks" 
                SortExpression="pointValue" />
            <asp:BoundField DataField="questionText" HeaderText="Question"  HtmlEncode="False" HtmlEncodeFormatString="False" />
            <asp:BoundField DataField="answer" HeaderText="Answer" HtmlEncode="False" 
                HtmlEncodeFormatString="False" />
            <asp:commandfield showeditbutton="true" showdeletebutton="true"
            buttontype="Image"
            editimageurl="pictures/EditButton.png"
            cancelimageurl="pictures/CancelButton.png"
            updateimageurl="pictures/UpdateButton.png"
            deleteimageurl="pictures/DeleteButton.png"
            headertext="Edit Controls"/>
        </Columns>
    </asp:GridView>
    </div>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ExamQuestionsConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:ExamQuestionsConnectionString.ProviderName %>" 
        UpdateCommand="UPDATE [question] SET [examBoardID] = @examBoardID, [examTypeID] = @examTypeID, [SubjectID] = @SubjectID, [questionText] = @questionText, [pointValue] = @pointValue, [answer] = @answer WHERE [questionID] = ?"
        SelectCommand="SELECT * FROM [question] WHERE ([author] = ?)" 
        DeleteCommand="DELETE FROM [question] WHERE [questionID] = ?" 
        InsertCommand="INSERT INTO [question] ([questionID], [examBoardID], [examTypeID], [SubjectID], [questionText], [pointValue], [answer], [attachment], [author]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)">
        <DeleteParameters>
            <asp:Parameter Name="questionID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="questionID" Type="Int32" />
            <asp:Parameter Name="examBoardID" Type="String" />
            <asp:Parameter Name="examTypeID" Type="String" />
            <asp:Parameter Name="SubjectID" Type="String" />
            <asp:Parameter Name="questionText" Type="String" />
            <asp:Parameter Name="pointValue" Type="Int32" />
            <asp:Parameter Name="answer" Type="String" />
            <asp:Parameter Name="attachment" Type="String" />
            <asp:Parameter Name="author" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="author" QueryStringField="author" 
                Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="examBoardID" Type="String" />
            <asp:Parameter Name="examTypeID" Type="String" />
            <asp:Parameter Name="SubjectID" Type="String" />
            <asp:Parameter Name="questionText" Type="String" />
            <asp:Parameter Name="pointValue" Type="Int32" />
            <asp:Parameter Name="answer" Type="String" />
            <asp:Parameter Name="questionID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
</asp:Content>
